﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace SEO.EmailSearch
{
    public partial class KeywordAddFrm : Form
    {
        public KeywordAddFrm()
        {
            InitializeComponent();
            skinEngine1.SkinFile = SEO.Utility.CommonHelper.GetCurrentSoftSkin();
            this.Icon = new Icon(SEO.Utility.ICONHelper.SetFormICON());
        }

        private void btnSubmit_Click(object sender, EventArgs e)
        {
            try
            {
                string strKeywordName = txtKeywordsName.Text.Trim();
                if (string.IsNullOrEmpty(strKeywordName))
                {
                    lblMessage.Text = "关键词不能为空!";
                }
                else
                {
                    //加入数据库
                    SEO.DAL.ESKeywordsDAL keyworddal = new DAL.ESKeywordsDAL();
                    if (!keyworddal.CheckEmailAddressIsExist(strKeywordName))
                    {
                        SEO.BLL.ESKeywordsBLL keywordbll = new BLL.ESKeywordsBLL();
                        SEO.Model.ESKeywords keyword = new Model.ESKeywords();
                        keyword.KeyID = keyworddal.GetAutoAddNum();
                        keyword.KeyName = strKeywordName;
                        keywordbll.InsertESKeywordsBLL(keyword);

                        lblMessage.Text = "添加成功!";
                    }
                    else
                    {
                        lblMessage.Text = "关键词已存在，请更换!";
                    }
                }
            }
            catch (Exception ex)
            {
                SEO.Utility.Log.SaveErrorLog("添加关键词 -> " + ex.Message);
            }
        }

        private void KeywordAddFrm_Load(object sender, EventArgs e)
        {
            lblMessage.ForeColor = Color.FromArgb(255, 0, 0);
        }
    }
}
